package com.mango.facade;

import com.mango.facade.common.result.ResultModel;
import com.mango.facade.common.util.ResultUtil;
import com.mango.facade.param.TemplateAttribute;
import com.mango.service.TemplateAttributeService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/template/attribute")
public class TemplateAttributeController {

    @Autowired
    private TemplateAttributeService templateAttributeService;


    @GetMapping(value = "/get")
    public ResultModel<List<TemplateAttribute>> getAttributeList(@RequestParam String templateName) {
        if (StringUtils.isBlank(templateName)) {
            ResultUtil.fail("参数不可为空");
        }
        //为空设置父ID
        List<TemplateAttribute> templateAttributeList = templateAttributeService.getAttributeList(templateName);
        return ResultUtil.success(templateAttributeList);
    }

}
